home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / net / netRoute.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  4.3 KB  |  136 lines

  1. /*
  2.  * netRoute.h --
  3.  *
  4.  *    Definitions for the routing part of the network module.
  5.  *    Other modules specify a Sprite host ID when sending messages
  6.  *    via the net module.  The net module maintains routing
  7.  *    information that maps from these Sprite host IDs to physical addresses.
  8.  *
  9.  * Copyright 1986, 1988 Regents of the University of California
  10.  * Permission to use, copy, modify, and distribute this
  11.  * software and its documentation for any purpose and without
  12.  * fee is hereby granted, provided that the above copyright
  13.  * notice appear in all copies.  The University of California
  14.  * makes no representations about the suitability of this
  15.  * software for any purpose.  It is provided "as is" without
  16.  * express or implied warranty.
  17.  *
  18.  *
  19.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/net/netRoute.h,v 9.9 92/06/03 22:48:01 voelker Exp $ SPRITE (Berkeley)
  20.  */
  21.  
  22. #ifndef _NETROUTE
  23. #define _NETROUTE
  24.  
  25. #ifdef KERNEL
  26. #include <sprite.h>
  27. #include <list.h>
  28. #include <netInet.h>
  29. #include <user/net.h>
  30. #include <netTypes.h>
  31. #else
  32. #include <sprite.h>
  33. #include <list.h>
  34. #include <netInet.h>
  35. #include <net.h>
  36. #include <kernel/netTypes.h>
  37. #endif
  38.  
  39. /*
  40.  * Maximum size for all headers of a packet.  We allow 8 extra bytes for
  41.  * alignment purposes.
  42.  */
  43. #define NET_MAX_HEADER_SIZE (sizeof(Net_UltraHeader) + sizeof(Net_IPHeader) + 8)
  44.  
  45. #ifdef KERNEL
  46. /*
  47.  * A Route: A mapping between a physical address and a Sprite Host ID.
  48.  * The supported address type is just ethernet. Net_Routes are manipulated
  49.  * by Net_InstallRoute and Net_AddrToID.  The main point of a Net_Route
  50.  * is that it holds a pre-packaged transport header that is pre-pended
  51.  * onto messages being sent to the Sprite Host.
  52.  *
  53.  */
  54. typedef struct Net_Route {
  55.     List_Links        links;        /* Used to add routes to a list. */
  56.     int            routeID;    /* ID unique to this route. */
  57.     int            protocol;    /* see values defined below */
  58.     Net_Address        netAddress[NET_MAX_PROTOCOLS];/* host addresses */
  59.     int            spriteID;    /* Universal Sprite ID */
  60.     int            flags;        /* See below. */
  61.     int            refCount;    /* Reference count. */
  62.     char        desc[64];    /* Route description.  Useful
  63.                      * for debugging. */
  64.     Address        headerPtr[NET_MAX_PROTOCOLS]; /* Start of transport 
  65.                                * headers*/
  66.     Net_Interface    *interPtr;    /* Which network interface to use. */
  67.     int            minPacket;    /* Minimum packet size of route. */
  68.     int            maxPacket;    /* Maximum packet size of route. */
  69.     int            minRpc;        /* Minimum RPC size for route. */
  70.     int            maxRpc;        /* Maximum RPC size for route. */
  71.     ClientData        userData;    /* Space available for user program
  72.                      * that manipulates routes. */
  73.     char        buffer[NET_MAX_HEADER_SIZE];  /* Network packet 
  74.                                * header(s). */
  75. } Net_Route;
  76.  
  77. #endif
  78. /*
  79.  * Flag values for Net_Route.
  80.  */
  81.  
  82. #define NET_RFLAGS_VALID    0x1    /* The route is valid. */
  83. #define NET_RFLAGS_DELETING    0x2    /* Route is being deleted. */
  84.  
  85. /*
  86.  * The following two constants define the minimum and maximum
  87.  * number of free routes on the free list.  Once the number drops
  88.  * below the minimum we add routes to the list until there are the
  89.  * maximum.  Make sure that the difference between the minimum and
  90.  * maximum is enough to allocate all of the broadcast routes during
  91.  * initialization since the callback stuff is initialized later.
  92.  */
  93.  
  94. #define NET_MIN_FREE_ROUTES 8
  95. #define NET_MAX_FREE_ROUTES (NET_MIN_FREE_ROUTES + NET_MAX_INTERFACES + 2)
  96.  
  97. /*
  98.  *  Variables corresponding to the above two constants.
  99.  */
  100.  
  101. extern    int    netMinFreeRoutes;
  102. extern    int    netMaxFreeRoutes;
  103.  
  104. /*
  105.  * This structure contains host information that is common to all routes
  106.  * to the host. The name is used for error reporting.
  107.  * The machine type is queried by the file system when it has to expand
  108.  * $MACHINE during pathname lookup.
  109.  */
  110.  
  111. typedef struct NetHostInfo {
  112.     char    name[20];        /* The host name. */
  113.     char    machType[12];        /* Host machine type. */
  114.     int        routes;            /* Number of routes that have ever
  115.                      * been installed to this host. */
  116. } NetHostInfo;
  117.  
  118. /*
  119.  * The routing table
  120.  */
  121. extern List_Links netRouteArray[];
  122. extern NetHostInfo netHostInfo[];
  123.  
  124.  
  125. /*
  126.  * Forward declarations.
  127.  */
  128.  
  129. extern void NetArpInput _ARGS_((Net_Interface *interPtr, Address packetPtr, 
  130.                 int packetLength));
  131. extern void NetAddToFreeRouteList _ARGS_((ClientData data, 
  132.                 Proc_CallInfo *infoPtr));
  133. extern void NetFreeRoute _ARGS_((Net_Route *routePtr));
  134.  
  135. #endif /* _NETROUTE */
  136.